package com.hanyxx.coll;

import java.util.ArrayList;
import java.util.Collections;

/**
 * @author layman
 * @date 2021/2/28
 */
public class Poker {
    //牌堆
    private static ArrayList<String> pokerBox = new ArrayList<>();
    //花色集合
    private static ArrayList<String> colors = new ArrayList<>();
    //创建数字集合
    private static ArrayList<String> numbers = new ArrayList<>();
    //三名玩家
    private static ArrayList<String> playerOne = new ArrayList<>();
    private static ArrayList<String> playerTwo = new ArrayList<>();
    private static ArrayList<String> playerThree = new ArrayList<>();
    private static ArrayList<String> diPai = new ArrayList<>();

    public static void main(String[] args) {
        createPoker();
        faPai();
        showCards();
    }
    /**
    * 创建扑克牌并洗牌
    */
    public static void createPoker(){
        //4种花色
        colors.add("♥");
        colors.add("♦");
        colors.add("♠");
        colors.add("♣");
        //13个数字
        for(int i = 2;i <= 10;i++){
            numbers.add(i+"");
        }
        numbers.add("J");
        numbers.add("Q");
        numbers.add("K");
        numbers.add("A");
        //生成扑克牌
        for (String color : colors) {
            for(String number : numbers){
                String card = color+number;
                pokerBox.add(card);
            }
        }
        pokerBox.add("小王");
        pokerBox.add("大王");
        //洗牌（随机打乱扑克牌顺序）
        Collections.shuffle(pokerBox);
    }
    /**
     * 发牌
     */
    public static void faPai(){
        //发牌
        for(int i = 0;i < pokerBox.size();i++){
            String card = pokerBox.get(i);
            if(i >= 51){
                //最后三张作为底牌
                diPai.add(card);
            } else {
                if(i%3 == 0){
                    playerOne.add(card);
                }else if(i%3 == 1){
                    playerTwo.add(card);
                }else{
                    playerThree.add(card);
                }
            }
        }
    }
    /**
     * 看牌
     */
    public static void showCards(){
        System.out.println("赌圣：" + playerOne);
        System.out.println("赌侠：" + playerTwo);
        System.out.println("赌王：" + playerThree);
        System.out.println("底牌：" + diPai);
    }
}
